package com.moutai.wmo.core.security.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.moutai.wmo.core.mybatis.TypeHandler.TrimStringTypeHandler;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

@Data
@TableName(value = "users", autoResultMap = true)
public class User implements UserDetails {

    @TableField(value = "username", typeHandler = TrimStringTypeHandler.class)
    private String username;

    @TableField(value = "password", typeHandler = TrimStringTypeHandler.class)
    private String password;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }


    /**
     * 账号 未过期|已过期
     *
     * @return boolean
     */
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    /**
     * 账号 未锁定|已被锁定
     *
     * @return boolean
     */
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    /**
     * 凭证 未过期|已过期
     *
     * @return boolean
     */
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    /**
     * 账号 已启用|被禁用
     *
     * @return boolean
     */
    @Override
    public boolean isEnabled() {
        return true;
    }
}
